import Http from "../utils/http";
import {formdata} from '../utils/util'
import Base from "./base"
class Service extends Base {
  // 实例方法需要维护状态
  // 静态方法不能获取实例属性的值

  /**
   * 分页查询项目列表
   * @param {*} pageNum 页码
   * @param {*} pageSize 每页数量
   * @param {*} type 类型
   * @param {*} projectName 关键词
   */
  async getList(type=null,value=null) {
    // 先判断是否有更多数据
    if(!this.hasMoreData) {
      return this.data
    }
    // 发起网络请求，获取数据
    const list = await Http.request({
      url: '/projectManage/selectProjectList', 
      data: formdata({
        pageNum: this.pageNum, 
        pageSize: this.pageSize,
        type: type,
        projectName: value
      }),
      method : 'POST',
      header: {
        'content-type': 'multipart/form-data; boundary=XXX'
      },
    })
    this.data = this.data.concat(list.rows)
    this.hasMoreData = !(this.pageNum === list.pages)
    this.pageNum ++
    return {
      data: this.data,
      underWayCount: list.underWayCount,
      completedCount: list.completedCount
    }
  }
  static getProject() {
    // 发起网络请求，获取数据
    return Http.request({
      url: '/projectManage/selectProjectList', 
      data: formdata({
        pageNum: 1, 
        pageSize: 3,
        type: 0
      }),
      method : 'POST',
      header: {
        'content-type': 'multipart/form-data; boundary=XXX'
      },
    })
  }
  // 获取项目基本信息
  static getProjectById(data) {
    return Http.request({
        url: `/projectManage/selectProjectInfo`,
        data,
        method: 'POST'
    })
  }

  // 获取进度信息
  static getProgressById(data) {
    return Http.request({
        url: '/projectManage/selectProgressSummary',
        data,
        method: 'POST'
    })
  }

  // 获取文件清单
  static getFileList(data) {
    return Http.request({
        url: '/projectManage/selectTempTree',
        data,
        method: 'POST'
    })
  }
  // 查看驳回详情
  static getFileDetail(data) {
    return Http.request({
        url: '/projectManage/selectFileRejectInfo',
        data,
        method: 'GET'
    })
  }
  // 获取专家意见
  static getSpecialist(data) {
    return Http.request({
        url: '/projectManage/selectExpertReviewList',
        data,
        method: 'POST'
    })
  }
  // 获取专家意见详情
  static getSpecialistDetail(data) {
    return Http.request({
        url: '/projectManage/getExpertsInfoById',
        data,
        method: 'POST'
    })
  }
  // 修改单个材料审核状态
  static updateMaterialsSubmitStatus(data) {
    return Http.request({
        url: '/projectManage/updateMaterialsSubmitStatus',
        data,
        method: 'POST'
    })
  }
   // 获取专家意见的附件列表
   static getFilesByOwnerType(data) {
    return Http.request({
        url: '/minioApp/getFilesByOwnerType',
        data,
        method: 'POST'
    })
  }
  // 获取首页信息
  static getHomeList() {
    return Http.request({
        url: '/message/selectAgendaMailReceiveList',
        method: 'POST'
    })
  }
}

export default Service